/*
 * @lc app=leetcode.cn id=383 lang=cpp
 *
 * [383] 赎金信
 */

// @lc code=start
class Solution
{
public:
  bool canConstruct(string ransomNote, string magazine)
  {
    unordered_map<char, int> m;
    for (char& c : magazine)
      m[c]++;
    for (char& c : ransomNote)
      if (m.find(c) == m.end() || --m[c] < 0)
        return false;
    return true;
  }
};
// @lc code=end
